<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <link rel="stylesheet" type="text/css" href="static/css/default.css"
              media="all" />
        <link rel="stylesheet" type="text/css" href="static/css/layout.css"
              media="all" />
        <link rel="stylesheet" type="text/css" href="static/css/general.css" />
        <link rel="stylesheet" type="text/css"
              href="static/css/jquery.theme.css" media="all" />
        <link rel="stylesheet" type="text/css" href="static/css/jquery.core.css"
              media="all" />

        <link rel="stylesheet" type="text/css"
              href="static/css/jquery.ui.button.css" media="all" />
        <link rel="stylesheet" type="text/css"
              href="static/css/jquery.ui.dialog.css" media="all" />
        <link rel="stylesheet" type="text/css"
              href="static/css/jquery.ui.menu.css" media="all" />
        <link rel="stylesheet" type="text/css"
              href="static/css/jquery.ui.override.css" media="all" />
        <link rel="stylesheet" type="text/css"
              href="static/css/jquery.ui.tab.css" media="all" />
        <link rel="stylesheet" type="text/css"
              href="static/css/list_favorite.css" media="all" />

        <link rel="stylesheet" type="text/css" href="static/css/user-own.css"
              media="all" />
        <link rel="stylesheet" type="text/css" href="static/css/profile.css"
              media="all" />
        <style type='text/css'>
            .progress {
                position: relative;
                width: 200px;
                border: 1px solid #ddd;
                padding: 1px;
                border-radius: 3px;
            }

            .bar {
                background-color: #B4F5B4;
                width: 0%;
                height: 20px;
                border-radius: 3px;
            }

            .percent {
                position: absolute;
                display: inline-block;
                top: 3px;
                left: 48%;
            }
        </style>
        <script type='text/javascript' src='static/js/jquery.min.js'></script>
        <script type='text/javascript' src='static/js/jquery.ui.core.js'></script>
        <script type='text/javascript' src='static/js/jquery.ui.widget.js'></script>

        <script type='text/javascript' src='static/js/jquery.ui.button.js'></script>
        <script type='text/javascript' src='static/js/jquery.ui.mouse.js'></script>
        <script type='text/javascript' src='static/js/jquery.ui.position.js'></script>
        <script type='text/javascript' src='static/js/jquery.ui.dialog.js'></script>
        <script type='text/javascript' src='static/js/jquery.ui.tab.js'></script>
        <script type='text/javascript' src='static/js/jquery.form.js'></script>
        <script type='text/javascript' src='static/js/jquery.ui.menu.js'></script>
        <script type='text/javascript' src='static/js/general.js'></script>
        <script type='text/javascript' src='static/js/renderdate.js'></script>
        <script type='text/javascript' src='static/js/validation.js'></script>
        <script type='text/javascript' src='static/js/profile.js'></script>
    </head>
    <body>
        <div class="body">
            <div class="header">
                <div class="float-left text-left login">
                    <span>Welcome lampart.com.</span>
                    <a id="request" class="sign-in" href="index.php?c=request">Request(<?php echo $this->numRequest; ?>)</a> |
                    <a id="signin" class="sign-in" href="index.php?c=logout">Sign out</a>
                </div>

            </div>
            <div class="search">
                <div class="social-connect"></div>
                <div class="logo">
                    <a href="#" title="">Lampart.com</a>
                </div>
                <div class="search-control">
                    <form action="index.php?c=search" method="get" id="search_control">
                        <div class="search-category">
                            <div id="search_title" class="search-title">
                                <span id="search_category_title" style="font-size: 10px;">All </span>
                                <img src="images/arrow_down.png" />
                            </div>
                            <ul id="search_menu" class="search-menu">
                                <li id="0" class="menu-option">All</li>
                                <li id="1" class="menu-option">Male</li>
                                <li id="2" class="menu-option">Female</li>
                            </ul>
                        </div>
                        <input type="hidden" id="search_controller" value="search" name="c" />
                        <input type="hidden" id="search_sex" value="" name="search[sex]" />
                        <input type="text" name="search[name]" size="15" /> <input
                            type="submit" id="search" name="search[search]" value="Search" />
                    </form>
                </div>
            </div>
            <div class="content">
                <div class="left">
                    <div class="control">
                        <a href="index.php">Home</a>
                    </div>
                    <div></div>
                </div>
                <div class="main-content">
                    <div class="profile">
                        <h2>
                            <span class="header-page">Profile</span>
                        </h2>
                        <br />
                        <div>
                            <div class="main">
                                <div class="image" id="image_profile" style="float: left;">
                                    <div id="text_picture">
                                        <img id='profile_user' width='150px' height='150px' src="<?php echo!empty($this->profile->picture) ? 'img/profile/' . $this->profile->picture : 'img/0.gif'; ?>" /><br />
                                    </div>
                                    <?php if($this->userLog->id == $this->userViewId):  ?>
                                    <div id="picture" style="display: none; position: absolute; background-color: #ccc; padding: 10px;" >
                                         <div style="color: red;" class='error' id='er_picture'></div>
                                        <form method='post' action='index.php?c=index&m=updateprofile' id='profile_form' name='form' enctype='multipart/form-data'>
                                            <input type='hidden' id='profile_id' name='profile[id]' value='42' />
                                            <input type="file" name="file" />
                                            <input type="submit" value="Upload">
                                            <input type="button" value="Cancel" id='cancel_upload_profile'>
                                        </form>
                                    </div>
                                    <a class='edit' id='edit_picture' href='#'>Edit</a>
                                    <?php endif; ?>
                                    <!-- <a id="update_picture" class="update" href="#" style='display: none;'>Update</a>-->
                                </div>
                                <div  style="float: left; width: 326px;">
                                <table>
                                    <tr>
                                        <td colspan='3' class="profile_detail"><span id='text_fullname'><?php echo!empty($this->profile) ? $this->profile->fullname : ''; ?>
                                            </span>
                                            <?php if($this->userLog->id == $this->userViewId):  ?>
                                            <input type='text' value="<?php echo!empty($this->userLog) ? $this->profile->fullname : ''; ?>" id="fullname" name="fullname" style='display: none;' /> <br />
                                            <div><span class='error' id='er_fullname'></span><br /></div>
                                            <a class='edit' id='edit_fullname' href='#'>Edit</a> <a
                                                id="update_fullname" class="update" href="#"
                                                style='display: none;'>Update</a>
                                            <a id="cancel_fullname" class="cancel" href="#" style='display: none;'>Cancel</a>
                                            <?php endif; ?>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class="profile_head">Username:</td>
                                        <td class="profile_detail" id='insert_username'><span
                                                id='text_username'><?php echo!empty($this->profile) ? $this->profile->username : ''; ?>
                                            </span>
                                            <?php if($this->userLog->id == $this->userViewId):  ?>
                                            <input type='text' value="<?php echo!empty($this->profile) ? $this->profile->username : ''; ?>" id="username" name="username" style='display: none;' />
                                            <br /><span class='error' id='er_username'></span>
                                        </td>
                                        <td><a class='edit' id='edit_username' href='#'>Edit</a>
                                        <a id="update_username" class="update" href="#" style='display: none;'>Update</a>
                                        <a id="cancel_username" class="cancel" href="#" style='display: none;'>Cancel</a>
                                            <?php endif; ?>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class="profile_head">Email:</td>
                                        <td class="profile_detail" id='insert_email'><span
                                                id='text_email'><?php echo!empty($this->profile) ? $this->profile->email : ''; ?>
                                            </span>
                                            <?php if($this->userLog->id == $this->userViewId):  ?>
                                            <input type='text'
                                                           value="<?php echo!empty($this->profile) ? $this->profile->email : ''; ?>"
                                                           id="email" name="email" style='display: none;' />
                                            <br /><span class='error' id='er_email'></span>
                                            <?php endif; ?>
                                        </td>
                                        <td>
                                            <?php if($this->userLog->id == $this->userViewId):  ?>
                                            <a id='edit_email' class='edit' href='#'>Edit</a>
                                            <a id="update_email" class="update" href="#" style='display: none;'>Update</a>
                                             <a id="cancel_email" class="cancel" href="#" style='display: none;'>Cancel</a>
                                            <?php endif; ?>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class="profile_head">Sex:</td>
                                        <td class="profile_detail">
                                            <div id="text_sex">
                                                <?php echo!empty($this->profile) ? $this->profile->sex == 1 ? 'Male' : 'Female'  : ''; ?>
                                            </div>
                                            <?php if($this->userLog->id == $this->userViewId):  ?>
                                            <div id="sex" style='display: none;'>
                                                <input type='radio' name='user[sex]' id='sex_male' value='1'
                                                       <?php echo!empty($this->profile) ? ($this->profile->sex == 1 ? 'checked="checked"' : '') : ''; ?> />Male
                                                <input type='radio' name='user[sex]' id='sex_female'
                                                       value='2'
                                                       <?php echo!empty($this->profile) ? ($this->profile->sex == 2 ? 'checked="checked"' : '') : ''; ?> />Female
                                            </div>
                                            <?php endif; ?>
                                        </td>
                                        <td>
                                            <?php if($this->userLog->id == $this->userViewId):  ?>
                                            <a id="edit_sex" class='edit' href='#'>Edit</a>
                                            <a id="update_sex" class="update" href="#" style='display: none;'>Update</a>
                                             <a id="cancel_sex" class="cancel" href="#" style='display: none;'>Cancel</a>
                                            <?php endif; ?>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class="profile_head">Birthday:</td>
                                        <td class="profile_detail">
                                            <div id="text_birthday">
                                                <?php echo!empty($this->profile) ? date('m-d-Y', strtotime($this->profile->birthday)) : ''; ?>
                                            </div>
                                            <?php if($this->userLog->id == $this->userViewId):  ?>
                                            <div id="birthday" style="display: none; width: 164px;">
                                                <?php list($month, $day, $year) = explode('-', date('m-d-Y', strtotime($this->profile->birthday))); ?>
                                                <select id='month' name='user[month]'>
                                                    <?php foreach (@$this->month as $key => $val): ?>
                                                        <option
                                                        <?php
                                                        if (!empty($this->profile)) {
                                                            echo $key == $month ? "selected='selected'" : '';
                                                        }
                                                        ?>
                                                            value='<?php echo $key; ?>'>
                                                                <?php echo $val; ?>
                                                        </option>
                                                    <?php endforeach; ?>
                                                </select> <select id='day' name='user[day]'>
                                                    <?php foreach (@$this->day as $key => $val): ?>
                                                        <option
                                                        <?php
                                                        if (!empty($this->profile)) {
                                                            echo $key == $day ? "selected='selected'" : '';
                                                        }
                                                        ?>
                                                            value='<?php echo $key; ?>'>
                                                                <?php echo $val; ?>
                                                        </option>
                                                    <?php endforeach; ?>
                                                </select> <select id='year' name='user[year]'>
                                                    <?php foreach (@$this->year as $key => $val): ?>
                                                        <option
                                                        <?php
                                                        if (!empty($this->profile)) {
                                                            echo $key == $year ? "selected='selected'" : '';
                                                        }
                                                        ?>
                                                            value='<?php echo $key; ?>'>
                                                                <?php echo $val; ?>
                                                        </option>
                                                    <?php endforeach; ?>
                                                </select>
                                            </div>
                                            <?php endif; ?>
                                            <br /><span class='error' id='er_birthday'></span>
                                        </td>
                                        <td>
                                            <?php if($this->userLog->id == $this->userViewId):  ?>
                                            <a id="edit_birthday" class='edit' href='#'>Edit</a> <a
                                                id="update_birthday" class="update" href="#"
                                                style='display: none;'>Update</a>
                                                 <a id="cancel_birthday" class="cancel" href="#" style='display: none;'>Cancel</a>
                                           <?php endif; ?>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <a href='index.php?c=listuser'><input type='button' value='View other users' id='view_other' name='view_other' /></a>
                                        </td>
                                        <td>
                                            <a href='index.php?c=listfriend<?php echo empty($this->userView) ? '' : '&user=' . $this->userView; ?>'>List friends</a><br />
                                            <?php if($this->friendRelation == FRIEND_REQUEST): ?>
                                                <span><b>Friend request sent</b></span>
                                            <?php  endif; ?>
                                            <?php if($this->friendRelation == NOT_FRIEND): ?>
                                                <a class='add-friend' id='add_friend_<?php echo $this->userViewId; ?>' href='#'>Add friend</a>
                                            <?php endif; ?>
                                            <?php if($this->friendRelation == FRIEND): ?>
                                                <span><b>Friend</b></span>
                                            <?php endif; ?>

                                        </td>
                                    </tr>
                                </table>
                            </div>
                            </div>
                            <div style="clear: both;"></div>
                            <div id="tabs" style='width: 600px;'>
                                <ul>
                                    <li><a href="#introduction">Introduction</a>
                                    </li>
                                    <li><a href="#picture">Picture</a></li>
                                    <li><a href="#contact">Contact</a></li>
                                    <li><a href="index.php?c=index&m=statitics<?php echo!empty($this->_get['user']) ? '&user=' . $this->_get['user'] : ''; ?>">Statictics</a></li>
                                </ul>
                                <div id='introduction'>
                                	<span>General information</span>&nbsp;
									<?php // if($this->userLog->id == $this->userViewId):  ?>
									<a class="edit-intro" id="edit_introduction" href="#">Edit</a>
									<a class="update-intro" id="update_introduction" href="#" style="display: none;">Update</a>
									<?php //endif; ?>
									<hr />
									<div id="text_introduction">
									    <?php echo!empty($this->introduction) ? $this->introduction : ''; ?>
									</div>
									<textarea cols="83" rows="10" id="introduction12" style="display: none;"><?php echo!empty($this->introduction) ? $this->introduction : ''; ?></textarea>
                                </div>
                                <div id='picture'>
                                    <?php if($this->userLog->id == $this->userViewId):  ?>
                                    <div id='box_upload'>
                                        <div style="color: red" id="err_box_uplad"></div>
                                        <form id='form_upload' action="index.php?c=index&m=picture"
                                              method="post" enctype="multipart/form-data">
                                            <input type='text' value='' name='photo[name]' id='photo_name' />
                                            <input type='file' id="file_upload" name='file' /><br /> <input type="submit"
                                                                                           value="Upload">
                                        </form>
                                    </div>
                                    <?php endif; ?>
                                    <div id='show_image' style='display: table !important;'>
                                        <?php if($this->userLog->id == $this->userViewId):  ?>
                                        <div class='image' style="height:250px; width: 100px;">
                                        	<div style='padding-top: 80px;'>
                                        		<a class='upload' href='#' style='padding-top: 20px; font-size: 13px; font-weight: bold; color: blue;'>Upload photo</a>
                                        	</div>
                                        </div>
                                        <?php endif; ?>
                                        <?php
                                        if (!empty($this->photos)):
                                            foreach ($this->photos as $object):
                                                ?>
                                                <div class='image' style="height:250px;">
                                                    <a class='view-image'
                                                       id='view_image_<?php echo $object->id; ?>' href='#'> <img
                                                            width='100px' height='100px'
                                                            src='img/<?php echo $object->id; ?>.jpeg' /><br />
                                                    </a> <span><?php if(strlen($object->name)>5)
                                                                        echo substr($object->name, 0, 5) . '...';
                                                    else
                                                        echo $object->name;
                                                    //echo text::characterLimiter($object->name, 3); ?>
                                                    </span>
                                                    <span style="display:none" id='full_text_<?php echo $object->id; ?>'><?php echo $object->name; ?></span>
                                                    <br />
                                                    <?php if ($this->userLog->id == $object->user_id): ?>
                                                        <span><a class='del-image'id='del_<?php echo $object->id; ?>' href='#'>Delete</a> </span>
                                                    <?php endif; ?>
                                                    <div>
                                                        <span class='view-image' id='view_<?php echo $object->id; ?>'>View:
                                                            <?php echo $object->numView; ?>
                                                        </span><br />
                                                    </div>
                                                    <div>
                                                        <span class='like-image-text' id='like_text_<?php echo $object->id; ?>'>Like: <?php echo $object->numLike; ?>
                                                        </span><br />
                                                    </div>
                                                    <?php if (!$object->liked): ?>
                                                        <?php if ($this->userViewId != $this->userLog->id): ?>
                                                        <span><a class='like-image' id='like_<?php echo $object->id; ?>' href='#'>Like</a> </span>
                                                        <?php endif; ?>
                                                    <?php endif; ?>
                                                </div>
                                                <?php endforeach; endif; ?>
                                    </div>
                                </div>
                                <div id='contact'>
                                    <script type='text/javascript' src="http://maps.googleapis.com/maps/api/js?key=AIzaSyDY0kkJiTPVd2U7aTOAwhc9ySH6oHxOIYM&sensor=false"></script>
                                    <?php $location = !empty($this->profile->location) ? explode('|', $this->profile->location) : array(10.830782560875221, 106.72962856187951); ?>
                                    <input type='hidden' name='map[x]' id='map_x' value='<?php echo $location[0]; ?>' />
                                    <input type='hidden' name='map[x]' id='map_y' value ='<?php echo $location[1]; ?>'/>
                                    <input type='hidden' name='map[empty]' id='map_empty' value ='<?php echo!empty($this->profile->location) ? 1 : 0; ?>'/>
                                    <?php if($this->userLog->id == $this->userViewId):  ?>
                                    <div style="color: red" id="err_map"></div>
                                    <form action='' id='map' name='map'>
                                        <label for='coord_x'>X:</label><input type='text' id='coord_x' name='coord[x]' value='<?php echo!empty($this->userLog->location) ? $location[0] : ''; ?>' />
                                        <label for='coord_y'>Y:</label><input type='text' id='coord_y' name='coord[y]' value='<?php echo!empty($this->userLog->location) ? $location[1] : ''; ?>' /><br />
                                        <input type='submit' id='save_coord' name='map[save]' value='Save' />
                                    </form>
                                    <?php endif; ?>
                                    <div id="googleMap" style="width:580px;height:380px;"></div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <!--<div class="right"></div>-->
                </div>
            </div>
            <div class='image-show' id='image_show' title='Image view'>
            	<div id='name_picture' style='font-weight: bold;'></div>
                <img id='image_album' class='' src="img/30.jpeg" width="96%"
                     height="95%" />
            </div>


            <form id="update_form" name="update_form" action=""
                  style="display: none;">
                <input type='text' value="" id="" name="" /> <input type="hidden"
                                                                    id="token" name="token" value="<?php echo $this->_token; ?>" />
            </form>

    </body>
</html>
